//
//  LKCodeCashierViewController.m
//  Mideleague_Shop
//
//  Created by Zhiwang on 2020/7/7.
//  Copyright © 2020 Zhiwang. All rights reserved.
//

#import "LKCodeCashierViewController.h"

@interface LKCodeCashierViewController ()
@property(nonatomic,strong)UIView *bgView;
@property(nonatomic,strong)UIImageView *erweimaImageV;
@end

@implementation LKCodeCashierViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    WS(weakSelf)
    self.navigationItem.title = @"二维码收款";
    self.bgView = [self backPictureView];
    [self.view addSubview:self.bgView];
    [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view.mas_left).offset(20);
        make.right.equalTo(self.view.mas_right).offset(-20);
        make.top.equalTo(self.view.mas_top).offset(NAVIGATION_BAR_HEIGHT + 20);
        make.height.mas_equalTo(HEIGHT / 2);
    }];
    [self.bgView setLayerShadow:[UIColor lightGrayColor] offset:CGSizeMake(1, 1) radius:3];
    self.bgView.layer.cornerRadius = 5;
    LKBaseButton *bottomBtn = [LKBaseButton buttonWithFrame:CGRectZero type:UIButtonTypeCustom title:@"扫一扫收款" titleColor:COLOR_HEX(0x333333) layercorne:25 font:[UIFont fontWithName:@"PingFangSC-Medium" size: 16] backgroudColor:yellowDefaultColor AndActionBlock:^(UIButton * _Nonnull btn) {
        [weakSelf.navigationController popViewControllerAnimated:YES];
    }];
    [self.view addSubview:bottomBtn];
    [bottomBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.bgView.mas_bottom).offset(30);
        make.centerX.equalTo(self.view);
        make.left.equalTo(self.view).offset(20);
        make.height.mas_equalTo(50);
    }];
    [bottomBtn setLayerShadow:[UIColor lightGrayColor] offset:CGSizeMake(1, 1) radius:3];
    // Do any additional setup after loading the view.
}
-(UIView *)backPictureView{
    UIView *bgView = [[UIView alloc] init];
    bgView.backgroundColor = [UIColor whiteColor];
    LKBaseButton *headerBtn = [LKBaseButton buttonWithFrame:CGRectZero type:UIButtonTypeCustom title:[NSString stringWithFormat:@"￥ %@",self.price] titleColor:COLOR_HEX(0x333333) layercorne:0 font:[UIFont fontWithName:@"PingFangSC-Medium" size: 36] backgroudColor:[UIColor whiteColor] AndActionBlock:^(UIButton * _Nonnull btn) {

    }];
    [bgView addSubview:headerBtn];
    [headerBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(bgView.mas_top).offset(10);
        make.centerX.equalTo(bgView);
    }];
    self.erweimaImageV = [[UIImageView alloc] init];
    _erweimaImageV.image = [self generateQRCodeWithString:self.url Size:164];
//    [_erweimaImageV setImageWithURL:[NSURL URLWithString:self.url] placeholder:[UIImage imageNamed:@""]];
    [bgView addSubview:_erweimaImageV];
    [_erweimaImageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(headerBtn.mas_bottom).offset(10);
        make.centerX.equalTo(bgView);
        make.size.mas_equalTo(CGSizeMake(164, 164));
    }];
    LKBaseLabel *topLabel = [LKBaseLabel labelWithFrame:CGRectZero text:@"请顾客扫一扫向我付款" textColor:COLOR_HEX(0x333333) font:[UIFont fontWithName:@"PingFangSC-Regular" size:16] textAlignment:NSTextAlignmentCenter];
    [bgView addSubview:topLabel];
    [topLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_erweimaImageV.mas_bottom).offset(10);
        make.centerX.equalTo(bgView);
    }];
    
    return bgView;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
